import { createStore } from "vuex";

let token = sessionStorage.getItem("token");
// 默认语言
let historylang = localStorage.getItem("historylang");
const langDefault = historylang ? historylang : "zh-CN";
localStorage.setItem("historylang", langDefault);

const store = createStore({
  state() {
    return {
      token: token ? token : "",
      locale: langDefault,
    };
  },
  mutations: {
    settoken(state, value) {
      state.token = value;
    },
    setlocale(state, value) {
      localStorage.setItem("historylang", value);
      state.locale = value;// 更换语言
    },
  },
  actions: {},
  getters: {},
  modules: {},
});

export default store;
